<{include file=$module.'/header.php'}>
<div class="page add-comment" id="page-app-add-comment">
	<header class="bar bar-nav common-bar-nav">
		<a class="pull-left back"><i class="fa fa-arrow-left"></i></a>
		<h1 class="title">个人资料</h1>
		<a class="pull-right external" href="/<{$routeUrl}>/pwd">修改密码</a>
	</header>
	<{include file=$module.'/nav.php'}>
	<div class="content">
		<div class="list-block m-t-1">
			<ul>
				<li class="item-content item-link">
					<div class="item-inner">
						<div class="item-title">UID</div>
						<div class="item-after"><{$admin.id}></div>
					</div>
				</li>
				<li class="item-content item-link">
					<div class="item-inner">
						<div class="item-title">身份</div>
						<div class="item-after"><{$userLevels[$admin.level]}></div>
					</div>
				</li>
				<li class="item-content item-link">
					<div class="item-inner">
						<div class="item-title">姓名</div>
						<div class="item-after"><{$admin.realname}></div>
					</div>
				</li>
				<li>
					<a id="sex-actions" class="item-content item-link">
						<div class="item-inner">
							<div class="item-title">性别</div>
							<div class="item-after"><span id="sex"><{$sexRadio[$admin.sex]}></span></div>
						</div>
					</a>
				</li>
				<li class="item-content item-link">
					<div class="item-inner">
						<div class="item-title">手机</div>
						<div class="item-after"><{$admin.tel}></div>
					</div>
				</li>
				<li class="item-content item-link">
					<div class="item-inner">
						<div class="item-title">到期时间</div>
						<div class="item-after"><{$admin.vip_time}></div>
					</div>
				</li>
				<li class="item-content item-link">
					<div class="item-inner">
						<div class="item-title">定位</div>
						<div class="item-after">lng:<{$admin.lng}> lat:<{$admin.lat}></div>
					</div>
				</li>

			</ul>
		</div>

		<div id="allmap"></div>
		
		<div class="content-padded">
			<a href="javascript:;" class="button button-fill button-big button-danger submit-com" data-id="<{$info.id}>">退出登录</a>
		</div>
		</form>
	</div>
</div>


<!-- 获取地理位置 -->
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=81e32ed2284d7c5d5994e6d9c738eea0"></script>
<!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=81e32ed2284d7c5d5994e6d9c738eea0&plugin=AMap.Geocoder"></script> -->
<script>
$(function(){

	function getLocation() {
		var map, geolocation;
		map = new AMap.Map('allmap');
		map.plugin('AMap.Geolocation', function() {
			geolocation = new AMap.Geolocation({
				enableHighAccuracy: true //是否使用高精度定位，默认:true
			});
			geolocation.getCurrentPosition();
			AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
			AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
			
			function onComplete (data) {
				var point = data.position;
				$.post("/<{$routeUrl}>/setting", {do:'map',lng:point.lng,lat:point.lat}, function(response){
					if(response.code == 0){
						$.toast(response.msg);
						return false;
					}
					if(response.code == 1){
						$.toast(response.msg);
					}
				});
			}

			function onError (data) {
				console.log(data);
			}
		});
	}

	function getPositionInfo(data) {
		var point = data.position;
		$('#js-lat').html(point.lat);
		$('#js-lng').html(point.lng);
		var lnglatXY = [point.lng, point.lat]; //已知点坐标

		var map, geolocation;
		map = new AMap.Map('allmap');
		map.plugin('AMap.Geocoder', function() {
			geolocation = new AMap.Geocoder();
			geocoder.getAddress(lnglatXY, function(status, result) {
				if (status === 'complete' && result.regeocode) {
					var obj = result.regeocode.addressComponent;
					var position = result.regeocode.formattedAddress;
					position = position.replace(obj.province, '');
					position = position.replace(obj.district, '');
					position = position.replace(obj.city, '');
					$('#position').html(position);

					$.post("/<{$routeUrl}>/setting", {do:'map',lng:point.lng,lat:point.lat}, function(response){
						if(response.code == 0){
							$.toast(response.msg);
							return false;
						}
						if(response.code == 1){
							$.toast(response.msg);
						}
					});

				}
			});
		});
		return ;
	}


	getLocation();


	$(document).on('click', '.submit-com', function(){
		$.toast('退出成功', "/<{$module}>/login/logout");
	})

	//性别修改
	$(document).on("click","#sex-actions", function () {
		var buttons1 = [
			{
			text: '请选择',
			label: true
			},
			{
			text: '男性',
			bold: true,
			onClick: function() {

					$.post("/<{$routeUrl}>/<{$action}>", {do:'sex',sex:1}, function(response){
						if(response.code == 0){
							$.alert(response.msg);
							return;
						}
						if(response.code == 1){
							$.toast(response.msg,'/<{$routeUrl}>/setting');
						}
					});
				}
			},
			{
			text: '女性',
			color: 'danger',
			onClick: function() {
					$.post("/<{$controller}>/<{$action}>", {do:'sex',sex:0}, function(response){
						if(response.code == 0){
							$.alert(response.msg);
							return;
						}
						if(response.code == 1){
							$.toast(response.msg,'/<{$routeUrl}>/setting');
						}
					});
				}
			}
		];
		var buttons2 = [
			{
			text: '取消',
			bg: 'danger'
			}
		];
		var groups = [buttons1, buttons2];
		$.actions(groups);
	}); 
});

</script>
<{include file=$module.'/footer.php'}>